Solenoids are composed, as a rule, of several elements. These are, among others, a tube pipe receiving a magnet armature as well as a coil element, and, if necessary, a housing embracing or encircling the elements. In order to assemble the elements, as a rule, the coil element is slid on the tube pipe, and eventually fixed on the tube pipe with a fastening element, for example a nut. It is a disadvantage of the known solenoid that the coil element is arranged during mounting freely turning on the tube pipe, and therefore a defined fixing of the relative position cannot be carried until the fastening element has been screwed or put on. Another disadvantage of conventional solenoids is the fact that the fastening part, which is, for example, slipped on the tube pipe or screwed on a thread arranged on the tube pipe, can be loosened during the use of the solenoid, which always is accompanied by vibrations, and thus a working loose of tube pipe and coil element takes place which has unfavorable effects for the operation of the solenoid. The vibration can also cause the complete loosening of the fastening element from the other elements of the solenoid and the loss of it.